<template>
    <div class="updata-list-window"></div>
</template>

<script>
import { Dialog } from 'vant'
import { isLoginChose } from '_projectFn/login'

export default {
    name: 'UpdataListWindow',
    props: {
        isShow: {
            type: Boolean,
            default: false,
        },
        confirmButtonText: {
            type: String,
            default: '在线客服'
        },
        cancelButtonText: {
            type: String,
            default: '在线客服'
        },
        confirmButtonColor: {
            type: String,
            default: '#0077bf'
        },
        cancelButtonColor: {
            type: String,
            default: '#999999'
        },
        title: {
            type: String,
            default: ''
        },
        message: {
            type: String,
            default: '您符合显示条件！\n如果确定未显示请告知在线客服！'
        },
        closeOnClickOverlay: {
            type: Boolean,
            default: true,
        },
        className: {
            type: String,
            default: ''
        },
        width: {
            default: 280,
        },
        showCancelButton: {
            type: Boolean,
            default: false,
        }
    },
    watch: {
        isShow() {
            const that = this
            if (this.isShow) {
                Dialog.alert({
                    message: this.message,
                    title: this.title,
                    confirmButtonText: this.confirmButtonText,
                    cancelButtonText: this.cancelButtonText,
                    confirmButtonColor: this.confirmButtonColor,
                    cancelButtonColor: this.cancelButtonColor,
                    closeOnClickOverlay: this.closeOnClickOverlay,
                    showCancelButton: this.showCancelButton,
                    className: this.className,
                    width: this.width,
                    beforeClose(action, done) {
                        // console.log('action', action)
                        if (action === 'confirm') { // 点击更新列表
                            // that.$emit('updataList') // 触发更新列表事件
                            that.$emit('showService') // 触发打开客服事件
                        } else if (action === 'cancel') { // 点击在线客服
                            // that.$emit('showService') // 触发打开客服事件
                        }
                        that.$emit('closeUpdataListWindow') // 触发关闭更新列表弹窗事件
                        done()
                    }
                })
            } else {
                Dialog.close()
            }
        }
    }
}
</script>

<style lang="scss">

</style>